package com.group.service.impl;

import com.group.mapper.UserNumberMapper;
import com.group.pojo.User;
import com.group.mapper.UserMapper;
import com.group.pojo.UserNumber;
import com.group.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author group
 * @since 2021-09-06
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserNumberMapper userNumberMapper;

    @Override
    public List<User> findAllUser(User user) {
        return userMapper.findAllUser1(user);
    }

    @Override
    public boolean addUser(User user) {
        UserNumber userNumber = new UserNumber();
        userNumber.setStudentid(user.getStudenid());
        List<UserNumber> list = userNumberMapper.findAllUserNumber1(userNumber);
        if (list==null||list.size()==0)
            return false;
        return userMapper.addUser1(user) > 0;
    }

    @Override
    public boolean delUser(String[] ids) {
        return userMapper.delUser1(ids) > 0;
    }

    @Override
    public boolean updateUser(User user) {
        return userMapper.updateUser1(user) > 0;
    }
}
